﻿@model IEnumerable<BskLeague.Models.News>

@{
    ViewBag.Title = "Wiadomości";
}

<h2>Wiadomości</h2>

@if (User.IsInRole("Admin"))
{
    <p>
        <a href='@Url.Action("New")'>
            <img src="../../Content/images/new-icon.png" alt="nowy" />
        </a>
    </p>
}

@foreach (var news in Model)
{
    <hr />
    <div>
        <h4>
            @Html.ActionLink(@news.newsTitle, "Details", new { id = @news.newsId }) 
            @if (User.IsInRole("Admin"))
            {
                <a href='@Url.Action("Edit", new { id = @news.newsId })'>
                    <img src='../../Content/images/edit-icon.png' title='edytuj' alt='edytuj' />
                </a>
                <a href="javascript:if(confirm('Na pewno usunąć?')){window.location='/News/Delete/@news.newsId'}">
                    <img src='../../Content/images/delete-icon.png' title='usuń' alt='usuń' />
                </a>
            }
        </h4>
        <p class="news_list_date">@news.newsDate</p>
        <p>
            @(news.newsContent.Count() > 200 ? news.newsContent.Substring(0, 200) : news.newsContent)...
            <br />
            <p class="news_list_comments">
                <a href="/News/Details/@news.newsId#comments">Komentarze (@news.newsComments.Count())</a>
            </p>
        </p>
    </div>
}